package com.lanou.controller.imgController;

import com.github.pagehelper.PageInfo;
import com.lanou.bean.Rosi;
import com.lanou.bean.resultImgBean.*;
import com.lanou.service.RosiService;
import com.lanou.service.imgService.ImgService;
import com.lanou.utils.AjaxResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by dllo on 18/3/10.
 */
@Controller
public class ImgController {
    @Resource
    RosiService rosiService;
    @Resource
    private ImgService imgService;
    //导航数据:空间
    @ResponseBody
    @RequestMapping(value = "/findHome")
    public List<Home> fingHome(){
        return imgService.findHome();
    }
    //导航数据:局部
    @ResponseBody
    @RequestMapping(value = "/findLayout")
    public List<Layout> fingLayout(){
        return imgService.findLayout();
    }
    //导航数据:公装
    @ResponseBody
    @RequestMapping(value = "/findPub")
    public List<Pub> fingPub(){
        return imgService.findPub();
    }
    //导航数据:面积
    @ResponseBody
    @RequestMapping(value = "/findRoom")
    public List<Room> fingRoom(){
        return imgService.findRoom();
    }
    //导航数据:风格
    @ResponseBody
    @RequestMapping(value = "/findStyle")
    public List<Style> fingStyle(){
        return imgService.findStyle();
    }
    //导航数据:户型
    @ResponseBody
    @RequestMapping(value = "/findType")
    public List<Type> fingType(){
        return imgService.findType();
    }
    //desc:按点击量升序
    //根据 是否公装,户型,空间,局部,风格,公装,套图,面积获得相应的图片地址
    @ResponseBody
    @RequestMapping(value = "/findImg")
    public List<Img> findImg(
            @RequestParam(required = false, value = "desc")  Integer desc,
            @RequestParam(required = false, value = "category") Integer category,
            @RequestParam(required = false, value = "type") Integer typeId,
            @RequestParam(required = false, value = "home") Integer homeId,
            @RequestParam(required = false, value = "layout") Integer layoutId,
            @RequestParam(required = false, value = "style") Integer styleId,
            @RequestParam(required = false, value = "pub") Integer publicId,
            @RequestParam(required = false, value = "ROSI") Integer ROSIId,
            @RequestParam(required = false, value = "room") Integer roomId
    ) {
        return imgService.findImg(
                desc,
                category,
                typeId,
                homeId,
                layoutId,
                styleId,
                publicId,
                ROSIId,
                roomId);
    }
    //加分页功能
    @ResponseBody
    @RequestMapping(value = "/findImgPage")
    public PageInfo<Img> findImgPage(@RequestParam(required = false, value = "pageNo") Integer pageNo,
                                     @RequestParam(required = false, value = "pageSize") Integer pageSize,
                                     @RequestParam(required = false, value = "desc")  Integer desc,
                                     @RequestParam(required = false, value = "category") Integer category,
                                     @RequestParam(required = false, value = "type") Integer typeId,
                                     @RequestParam(required = false, value = "home") Integer homeId,
                                     @RequestParam(required = false, value = "layout") Integer layoutId,
                                     @RequestParam(required = false, value = "style") Integer styleId,
                                     @RequestParam(required = false, value = "pub") Integer publicId,
                                     @RequestParam(required = false, value = "ROSI") Integer ROSIId,
                                     @RequestParam(required = false, value = "room") Integer roomId){




        return imgService.findImgPage(pageNo,
                                      pageSize,
                                      desc,
                                      category,
                                      typeId,
                                      homeId,
                                      layoutId,
                                      styleId,
                                      publicId,
                                      ROSIId,
                                      roomId);

    }
    //套图分页
    @ResponseBody
    @RequestMapping(value = "/findROSIImgPage")
    public PageInfo<ROSI> findROSIImgPage(@RequestParam(required = false, value = "pageNo") Integer pageNo,
                                          @RequestParam(required = false, value = "pageSize") Integer pageSize){

        return imgService.findROSIImgPage(pageNo,pageSize);

    }

    /**
     * zfy
     * 通过ROSI_id 获得改组风格房子套图的详细信息
     * @param rosiid
     * @return
     */
    @ResponseBody
    @RequestMapping("/getImgMessage")
    public AjaxResult page(@RequestParam("rosiid") Integer rosiid) {

        return rosiService.getAllMessageByRosiId(rosiid);
    }

    /**
     * zfy
     * 作用页面：效果图页面
     * 分页显示所有精品套图
     * @param pageNo 当前页
     * @param pageSize 每页显示条数
     * @return
     */
    @ResponseBody
    @RequestMapping("/getAllImgMsg")
    public PageInfo<Rosi> pagePaging(@RequestParam(value = "pageno",required = false) Integer pageNo,
                                     @RequestParam(value = "pagesize",required = false) Integer pageSize){
        return rosiService.pageInfo(pageNo,pageSize);
    }


    /**
     * zfy
     * 作用页面：效果图页面
     * 精品套图页面下面推荐
     * @return
     */
    @ResponseBody
    @RequestMapping("/getfourimg")
    public AjaxResult fourImg(){
        return rosiService.getFourImg();
    }

}